{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Simple Scripts with SpecDB (v1.3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# imports"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Downloading a DataBase\n",
    "\n",
    "After installing specdb, you can grab the latest (or any\n",
    "previous) version of a given DB with its *get_xxxx* script.\n",
    "Here is the call for IgmSpec:\n",
    "\n",
    "    usage: specdb_get_igmspec [-h] [-v VERSION]\n",
    "\n",
    "    Grab the IGMspec DB\n",
    "\n",
    "    optional arguments:\n",
    "      -h, --help            show this help message and exit\n",
    "      -v VERSION, --version VERSION\n",
    "                            DB version to generate"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### IGMSpec :: specdb_get_igmspec"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### v02\n",
    "\n",
    "    specdb_get_igmspec -v v02"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "----"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Checking a DB file :: specdb_chk\n",
    "\n",
    "\n",
    "### Script to check the version and date of a given DB file"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Usage\n",
    "    wolverine-4.local> specdb_chk -h\n",
    "    usage: specdb_chk [-h] db_file\n",
    "\n",
    "    Check a specdb DB file\n",
    "\n",
    "    positional arguments:\n",
    "      db_file     Database file\n",
    "\n",
    "    optional arguments:\n",
    "      -h, --help  show this help message and exit"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example\n",
    "    profx.ucolick.org> specdb_chk ~/local/Python/igmspec/DB/IGMspec_DB_v02.hdf5\n",
    "    specdb DB file is from the igmspec database\n",
    "    specdb DB file version=v02 was created on 2016-Oct-25\n",
    "    Latest version for specdb DB type=igmspec is version=v02\n",
    "    Latest creation date for this DB version was 2016-10-25\n",
    "    Oldest valid DB file for this DB version was 2016-10-10\n",
    "    Dataset: 2QZ\n",
    "    Dataset: BOSS_DR12\n",
    "    Dataset: COS-Dwarfs\n",
    "    Dataset: COS-Halos\n",
    "    Dataset: ESI_DLA\n",
    "    Dataset: GGG\n",
    "    Dataset: HD-LLS_DR1\n",
    "    Dataset: HDLA100\n",
    "    Dataset: HSTQSO\n",
    "    Dataset: HST_z2\n",
    "    Dataset: KODIAQ_DR1\n",
    "    Dataset: MUSoDLA\n",
    "    Dataset: SDSS_DR7\n",
    "    Dataset: XQ-100\n",
    "    Dataset: catalog\n",
    "    Dataset: quasars"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "----"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Plot :: specdb_plot"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "    usage: specdb_plot [-h] [--tol TOL] [-g GROUP] [-s SELECT] [--mplot MPLOT]\n",
    "                       [--db_file DB_FILE]\n",
    "                       coord dbase\n",
    "\n",
    "\n",
    "    specdb_plot script v0.3\n",
    "\n",
    "    positional arguments:\n",
    "      coord                 Coordinates, e.g. J081240.7+320809 or 122.223,-23.2322\n",
    "                            or 07:45:00.47,34:17:31.1\n",
    "      dbase                 Database [igmspec,all,priv]\n",
    "\n",
    "    optional arguments:\n",
    "      -h, --help            show this help message and exit\n",
    "      --tol TOL             Maximum offset in arcsec [default=5.]\n",
    "      --meta                Show meta data? [default: True]\n",
    "      -g GROUP, --group GROUP\n",
    "                            Name of Group to use\n",
    "      --select SELECT       Index of spectrum to plot (when multiple exist)\n",
    "      --mplot MPLOT         Use simple matplotlib plot [default: False]\n",
    "      --db_file DB_FILE     Full path of db_file"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Examples"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### FJ0812+32\n",
    "    specdb_plot J081240.7+320808 igmspec --group KODIAQ_DR1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "#### J001115.23+144601.8\n",
    "    specdb_plot J001115.23+144601.8 igmspec"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "----"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Meta Data :: specdb_meta\n",
    "    specdb_meta -h\n",
    "    usage: specdb_meta [-h] [--tol TOL] [-g GROUP] [--db_file DB_FILE] coord dbase\n",
    "\n",
    "    specdb_meta script v0.1\n",
    "\n",
    "    positional arguments:\n",
    "      coord                 Coordinates, e.g. J081240.7+320809 or 122.223,-23.2322\n",
    "                            or 07:45:00.47,34:17:31.1\n",
    "      dbase                 Database [igmspec,uvqs,all,priv]\n",
    "\n",
    "    optional arguments:\n",
    "      -h, --help            show this help message and exit\n",
    "      --tol TOL             Maximum offset in arcsec [default=5.]\n",
    "      -g GROUP, --group GROUP\n",
    "                            Restrict on Group (e.g. BOSS_DR12)\n",
    "      --db_file DB_FILE     Full path of db_file"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example\n",
    "    profx>  specdb_meta J081240.7+320809 igmspec\n",
    "    Database is igmspec\n",
    "    Created on 2017-Jan-31\n",
    "    Your search yielded 1 match[es] within radius=5 arcsec\n",
    "    IGM_ID   GROUP    RA_GROUP DEC_GROUP zem_GROUP          SPEC_FILE          \n",
    "    ------ ---------- -------- --------- --------- ----------------------------\n",
    "     50676  BOSS_DR12 123.1695   32.1357     2.698 spec-3758-55506-0325.fits.gz\n",
    "     50676   SDSS_DR7 123.1695   32.1357     2.703 spSpec-52318-0861-333.fit.gz\n",
    "     50676 KODIAQ_DR1 123.1695   32.1357     2.712        J081240+320808_f.fits\n",
    "     50676    HDLA100 123.1695   32.1358     2.670            FJ0812+32B_f.fits\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "----"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Interface with SDSS/BOSS Database :: specdb_sdss"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "    usage: specdb_sdss [-h] [-s SURVEY] [--select SELECT] [-p] plate fiberid dbase\n",
    "\n",
    "    specdb_sdss script v0.1\n",
    "\n",
    "    positional arguments:\n",
    "      plate                 Plate\n",
    "      fiberid               FiberID\n",
    "      dbase                 Database [igmspec,all]\n",
    "\n",
    "    optional arguments:\n",
    "      -h, --help            show this help message and exit\n",
    "      -s SURVEY, --survey SURVEY\n",
    "                            Name of Survey to use (BOSS_DR12 or SDSS_DR7)\n",
    "      --select SELECT       Index of spectrum to plot (when multiple exist)\n",
    "      -p, --plot            Plot with lt_xspec"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example\n",
    "\n",
    "    UNIX> specdb_sdss 434 555 igmspec -p"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
